function se = CAT_prof1se(b,Xc,m,c,h,X,use,resid)

n = size(X,1);
nuse = numel(use);
buse = b(use);
Xcu = Xc(:,use);
Xu = X(:,use);

prof_deriv = ((CAT_prof1(buse*ones(1,nuse)+h*eye(nuse),Xcu,m,c) - CAT_prof1(buse*ones(1,nuse)-h*eye(nuse),Xcu,m,c))/(2*h))';

S1 = m*(Xcu*buse-c).*((Xcu*buse > c)-1) - mean(m*(Xcu*buse-c).*((Xcu*buse > c)-1));  % n x 1
Sb = Xu.*(resid*ones(1,size(Xu,2)))*inv(Xu'*Xu); %#ok<MINV>  n x pu
S2 = Sb*prof_deriv; % n x 1
S = S1/n+S2;

se = sqrt(S'*S);
